#include <iostream>
#include <algorithm>
using namespace std;
int data[52];
int n;
int main()
{     
    int i,t=0;
    while(cin >> n && n)
    {
    t++;
        int sum = 0;
        for(i = 0; i < n;i++)
         { 
            cin >> data[i];
             sum += data[i];
         }                 int avg = sum / n;
         int res = 0;
         while(true)
         {
             int *pos =max_element(data, data + n);
             int *pos2 = min_element(data, data + n);
             if(*pos == *pos2)
                 break;
             data[pos - data]--;
             data[pos2 -data]++;
            res++;
         }
     cout << "Set #" << t << endl;
         cout << "The minimum number of moves is " << res << '.' << endl << endl;
     }
     return 0; 
} 
